package symbols;

import java.awt.Checkbox;
import symbols.SymbolButton;
import javax.swing.JPanel;

/**
 * 
 * @author Balazs Pete
 *
 */
public class Toolbar extends JPanel {
	
	//Variable controlling the automatic spacing between symbols
	//private boolean enableSpaces = false;
	private Checkbox enableSpacesCB = new Checkbox("Spaces",false);
	
	//layout control 0-default
	private int layout = 0;
	//buttons array
	private SymbolButton[] buttons;
	
	/**
	 * Constructor for symbols toolbar
	 */
	public Toolbar (){
		new JPanel();
		addButtons();
	}
	
	/**
	 * Method to change layout
	 * @param l
	 */
	public void changeLayout(int l){
		//TODO
	}
	
	/**
	 * Adds the buttons from the array to the Panel
	 * @author Balazs Pete
	 */
	private void addButtons(){
		setLayout();
		for(int i=0;i<buttons.length;i++){
			buttons[i].setBounds(i*60,0,30,20);
			this.add(buttons[i]);
		}
	}
	
	/**
	 * Sets the layout
	 * @return button layout
	 * @author Balazs Pete
	 */
	private void setLayout(){
		if (layout==0){
			defaultLayout();
		}
	}
	
	/**
	 * Creates the default layout of buttons
	 * @return default layout
	 * @author Balazs Pete
	 */
	private void defaultLayout(){
		buttons = new symbols.SymbolButton[19];
		buttons[0] = new SymbolButton("\u2261","\u2261",40,30);
		buttons[1] = new SymbolButton("\u22C0","\u22C0",40,30);
		buttons[2] = new SymbolButton("\u22C1","\u22C1",40,30);
		buttons[3] = new SymbolButton("\u00AC","\u00AC",40,30);
		buttons[4] = new SymbolButton("\u21D2","\u21D2",40,30);
		buttons[5] = new SymbolButton("\u23BF","\u23BF",40,30);
		buttons[6] = new SymbolButton("\u23CC","\u23CC",40,30);
		buttons[7] = new SymbolButton("\u23BE","\u23BE",40,30);
		buttons[8] = new SymbolButton("\u23CB","\u23CB",40,30);
		buttons[9] = new SymbolButton("\u003C","\u003C",40,30);
		buttons[10] = new SymbolButton("\u003E","\u003E",40,30);
		buttons[11] = new SymbolButton("\u2264","\u2264",40,30);
		buttons[12] = new SymbolButton("\u2265","\u2265",40,30);
		buttons[13] = new SymbolButton("\u2291","\u2291",40,30);
		buttons[14] = new SymbolButton("\u2191","\u2191",40,30);
		buttons[15] = new SymbolButton("\u2193","\u2193",40,30);
		buttons[16] = new SymbolButton("\u2297","\u2297",40,30);
		buttons[17] = new SymbolButton("\u2203","\u2203",40,30);
		buttons[18] = new SymbolButton("\u2200","\u2200",40,30);
		
	}
	
	/**
	 * Returns the state of the enableSpacesCB
	 * @return state of checkbox, true if ticked
	 * @author Balazs Pete
	 */
	public boolean getSpacesCBStatus(){
		return enableSpacesCB.getState();
	}
}
